package com.ruoyi.web.controller.shopwebpublic;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.ShopCompanyInfo;
import com.ruoyi.system.domain.ShopScene;
import com.ruoyi.system.domain.ShopSoftware;
import com.ruoyi.system.service.IShopCompanyInfoService;
import com.ruoyi.system.service.IShopSceneService;
import com.ruoyi.system.service.IShopSoftwareService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopBottomInfo;
import com.ruoyi.system.service.IShopBottomInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 底部栏信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/system/bottom")
public class ShopBottomInfoController extends BaseController
{
    @Autowired
    private IShopBottomInfoService shopBottomInfoService;

    @Autowired
    private IShopCompanyInfoService shopCompanyInfoService;

    @Autowired
    private IShopSoftwareService shopSoftwareService;
    @Autowired
    private IShopSceneService shopSceneService;
    /**
     * 查询底部栏信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShopBottomInfo shopBottomInfo)
    {
        startPage();
        List<ShopBottomInfo> list = shopBottomInfoService.selectShopBottomInfoList(shopBottomInfo);
        return getDataTable(list);
    }
    /**
     * 查询企业，软件，应用场景的数量
     */
    @GetMapping("/getnums")
    public AjaxResult getnums()
    {
        //查询入住公司数量
        ShopCompanyInfo company = shopCompanyInfoService.getShopCompanyInfoTotal();
        ShopSoftware software =shopSoftwareService.getShopSoftwareTotal();
        ShopScene scene =shopSceneService.getShopSceneTotal();
        Map map = new HashMap();
        map.put("companyTotal",company.getTotal());
        map.put("softwareTotal",software.getTotal());
        map.put("sceneTotal",scene.getTotal());
        return success(map);
    }


    /**
     * 导出底部栏信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "底部栏信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopBottomInfo shopBottomInfo)
    {
        List<ShopBottomInfo> list = shopBottomInfoService.selectShopBottomInfoList(shopBottomInfo);
        ExcelUtil<ShopBottomInfo> util = new ExcelUtil<ShopBottomInfo>(ShopBottomInfo.class);
        util.exportExcel(response, list, "底部栏信息数据");
    }

    /**
     * 获取底部栏信息详细信息
     */
    @GetMapping(value = "/{bottomId}")
    public AjaxResult getInfo(@PathVariable("bottomId") Long bottomId)
    {
        return success(shopBottomInfoService.selectShopBottomInfoByBottomId(bottomId));
    }

    /**
     * 新增底部栏信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "底部栏信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopBottomInfo shopBottomInfo)
    {
        return toAjax(shopBottomInfoService.insertShopBottomInfo(shopBottomInfo));
    }

    /**
     * 修改底部栏信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "底部栏信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopBottomInfo shopBottomInfo)
    {
        return toAjax(shopBottomInfoService.updateShopBottomInfo(shopBottomInfo));
    }

    /**
     * 删除底部栏信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "底部栏信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bottomIds}")
    public AjaxResult remove(@PathVariable Long[] bottomIds)
    {
        return toAjax(shopBottomInfoService.deleteShopBottomInfoByBottomIds(bottomIds));
    }
}
